var countdown = 60;
var timeoutID;
function start() {
	Center();
}
function Center() {
	var h1 = document.documentElement.clientHeight;
	var w1 = document.documentElement.clientWidth;
	if (w1 > 1600) {
		document.getElementById("container").style.marginLeft = "-800px";
		document.getElementById("container").style.left = "50%";
		document.getElementById("container").style.width = "1600px"
	} else {
		document.getElementById("container").style.marginLeft = "0";
		document.getElementById("container").style.left = "0";
		document.getElementById("container").style.width = "100%"
	}
}
function trimall(strValue)
{
  var spacei=0;
  var intLen;
  var frontSpaceNum = 0;
  var endSpaceNum = 0;
  if (strValue.length==0) return ""
  else{
	  intLen = strValue.length;
	  for (spacei=0;spacei<intLen;spacei++){        // 去除前面的空格
	    if (strValue.charAt(spacei)==" "){
	      frontSpaceNum++;
	    }
	    else
	    	break;
	  }

	  for (spacei=1;spacei<intLen;spacei++){        // 去除后面的空格
	    if (strValue.charAt(intLen-spacei)==" "){
	      endSpaceNum++;
	    }
	    else
	      break;
	  }
	    if (frontSpaceNum==intLen){
	    	return "";
	    }
	  else{
		  strValue = strValue.substring(frontSpaceNum,strValue.length-endSpaceNum);
		  return strValue;
	  }
  }
}
function switchTab(type) {
	if(type == 'namelogin') {
		$('#lc-normal').show();
		$('#lc-phone').hide();
		$('#namelogin').addClass("on");
		$('#phonelogin').removeClass("on");
	}
	if(type == 'phonelogin') {
		$('#lc-phone').show();
		$('#lc-normal').hide();
		$('#phonelogin').addClass("on");
		$('#namelogin').removeClass("on");
	}
}
function namelogin_keyDown(e) {
	  var ev= window.event||e;

	//13是键盘上面固定的回车键
	  if (ev.keyCode == 13) {
//		  loginSubmit();
	  }
}
/**
 * 验证码图片
 */
function changeCode() {
	$("#kaptchaImage").attr('src',
			basePath + "/kaptcha.jpg?" + Math.floor(Math.random() * 100));
}
//获取短信验证码
function getMessageCode(){
	var phone = trimall($("#phoneinput").val());
//	if (phone.length == 0||"手机号"==phone||"帐号"==phone) {
//		errorMessage('请输入手机号!');
//		phoneloginSubmit.phone.focus();
//		return;
//	}		
//	if(false == checkMobileNum(phone)){
//		return ;
//	}else if(true == checkMobileNum(phone)){
//		removeMessage();
//	}
	settime();
	//采用Ajax方式提交
//	commonAjaxFormSubmit(basePath+"/page/login/getMessageCode","#phoneloginSubmitForm","getMessageCode",true);
}
//手机动态验证码的 倒计时定+时方法
function settime() { 
	if (countdown == 0) { 
		$("#getmasscode").show();
		$("#getpyzm").hide();
    	countdown = 60; 
    	$("#getpyzm").html(countdown +"秒后重新获取");
	} else{ 
		$("#getmasscode").hide();
		$("#getpyzm").show();
		$("#getpyzm").html(countdown +"秒后重新获取");
	    countdown--; 
	    timeoutID = setTimeout(function() { 
    		settime() ;
    		},1000) ;
	} 
}
//校验手机号
function checkMobileNum(phone){
	var flag = true;
	var re = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
	if(!re.test(phone)){
		errorMessage("请输入正确的手机号！");
		flag = false;
	}
	return flag;
}